using HtERP.Data;

namespace HtERP.Services
{
    public interface IBackupScheduleService
    {
        #region 备份计划管理
        /// <summary>
        /// 获取所有备份计划
        /// </summary>
        Task<List<BackupSchedule>> GetAllSchedulesAsync();
        
        /// <summary>
        /// 获取指定ID的备份计划
        /// </summary>
        /// <param name="id">计划ID</param>
        Task<BackupSchedule> GetScheduleByIdAsync(Guid id);
        
        /// <summary>
        /// 创建新的备份计划
        /// </summary>
        /// <param name="schedule">备份计划对象</param>
        Task<Guid> CreateScheduleAsync(BackupSchedule schedule);
        
        /// <summary>
        /// 更新备份计划
        /// </summary>
        /// <param name="schedule">备份计划对象</param>
        Task<bool> UpdateScheduleAsync(BackupSchedule schedule);
        
        /// <summary>
        /// 删除备份计划
        /// </summary>
        /// <param name="id">计划ID</param>
        Task<bool> DeleteScheduleAsync(Guid id);
        
        /// <summary>
        /// 启用或禁用备份计划
        /// </summary>
        /// <param name="id">计划ID</param>
        /// <param name="enabled">是否启用</param>
        Task<bool> ToggleScheduleStatusAsync(Guid id, bool enabled);
        
        /// <summary>
        /// 立即执行备份计划
        /// </summary>
        /// <param name="scheduleId">计划ID</param>
        Task<bool> ExecuteScheduleNowAsync(Guid scheduleId);
        #endregion
        
        #region 备份历史管理
        /// <summary>
        /// 获取指定备份计划的最新成功备份记录
        /// </summary>
        /// <param name="scheduleId">计划ID</param>
        Task<BackupHistory> GetLatestSuccessBackupHistoryAsync(Guid scheduleId);
        
        /// <summary>
        /// 获取备份历史记录列表
        /// </summary>
        /// <param name="scheduleId">可选，按计划ID筛选</param>
        /// <param name="startDate">可选，按开始日期筛选</param>
        /// <param name="endDate">可选，按结束日期筛选</param>
        /// <param name="successOnly">可选，是否只返回成功的记录</param>
        /// <returns>备份历史记录列表</returns>
        Task<List<BackupHistory>> GetBackupHistoryAsync(Guid? scheduleId = null, DateTime? startDate = null, DateTime? endDate = null, bool successOnly = false);
        
        /// <summary>
        /// 删除备份历史记录
        /// </summary>
        /// <param name="historyId">历史记录ID</param>
        /// <returns>是否删除成功</returns>
        Task<bool> DeleteBackupHistoryAsync(Guid historyId);
        
        /// <summary>
        /// 批量删除备份历史记录
        /// </summary>
        /// <param name="historyIds">历史记录ID列表</param>
        /// <returns>删除的记录数</returns>
        Task<int> BatchDeleteBackupHistoryAsync(List<Guid> historyIds);
        
        /// <summary>
        /// 添加备份历史记录
        /// </summary>
        /// <param name="historyItem">备份历史记录</param>
        Task<bool> AddBackupHistoryAsync(BackupHistory historyItem);
        #endregion
        
        #region 调度服务管理
        /// <summary>
        /// 获取服务是否正在运行
        /// </summary>
        bool IsRunning { get; }

        /// <summary>
        /// 启动备份调度服务
        /// </summary>
        void Start();

        /// <summary>
        /// 停止备份调度服务
        /// </summary>
        void Stop();
       
        #endregion
    }
}